﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows;

namespace AppUI
{
    public class NotifyIconViewModel
    {
        /// <summary>
        /// 激活窗口
        /// </summary>
        public ICommand ShowWindowCommand
        {
            get
            {
                return new DelegateCommand
                {
                    CommandAction = () =>
                    {

                        Application.Current.MainWindow.Show();
                        Application.Current.MainWindow.Activate();
                    }
                };
            }
        }

        /// <summary>
        /// 隐藏窗口
        /// </summary>
        public ICommand HideWindowCommand
        {
            get
            {
                return new DelegateCommand
                {
                    CommandAction = () => Application.Current.MainWindow.Hide()
                };
            }
        }


        /// <summary>
        /// 关闭软件
        /// </summary>
        public ICommand ExitApplicationCommand
        {
            get
            {
                return new DelegateCommand
                {
                    CommandAction = () =>
                    {

                        MessageBoxResult res = MessageBox.Show(Application.Current.MainWindow, "退出可能造成打印中的任务异常，是否确认退出？"
                   , "退出确认", MessageBoxButton.OKCancel, MessageBoxImage.Question);
                        if (MessageBoxResult.OK == res)
                        {
                            try
                            {
                                //Program.server.Stop();
                            }
                            catch { }
                            //notifyIcon1.Visible = false;
                            Application.Current.Shutdown();
                        }
                    }
                };
            }
        }
    }

}
